package com.zlkj.pro.core.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 正则校验工具
 *
 * @author 孙铭泽
 * @date 2022/3/29
 * @time 13:11
 */
public class RegularUtil {

    /**
     * 邮箱正则表达式
     */
    private final static String EMAIL_REGULAR = "\\w[-\\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\\.)+[A-Za-z]{2,14}";

    /**
     * 邮箱格式校验
     *
     * @param email 邮箱
     * @return true 成功 false 失败
     */
    public static boolean email(String email) {
        Pattern r = Pattern.compile(EMAIL_REGULAR);
        Matcher m = r.matcher(email);
        return m.matches();
    }

}
